package com.wuxx.quartz.job.impl;

import com.wuxx.quartz.job.QuartzTaskJob;
import com.wuxx.quartz.service.TaskService;
import com.wuxx.utils.PropertyUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.nutz.integration.quartz.annotation.Scheduled;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

@IocBean
@Scheduled(cron = "0/5 * * * * ? *")
public class DefaultTaskJobImpl implements QuartzTaskJob {

    private static Logger log = LogManager.getLogger(DefaultTaskJobImpl.class);
    private static String taskGroups =  PropertyUtils.getProperty("quartz.task-group");
    @Inject
    TaskService taskService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.debug("----------------------------默认任务开启，启动任务状态组【"+taskGroups+"】-------------------");
        taskService.startStaticTask(taskGroups);
    }
}
